Skip to content

feat(azurite): Enhance connection string generation for network and local access #859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

adendek
Copy link

@adendek adendek commented Aug 11, 2025

Resolves #851

This Pull Request enhances the AzuriteContainer to provide more flexible and robust connection strings, specifically enabling seamless communication between Azurite and other containers within the same Docker network. It also clarifies access from the local host, addressing the need for distinct connection types in containerized testing environments.


Key Changes

  • Introduces ConnectionStringType enum: This new enum allows specifying the intended access pattern when requesting an Azurite connection string:
    • NETWORK: Optimized for inter-container communication, leveraging Docker network aliases for direct connectivity.
    • LOCALHOST: Designed for access from the host machine, utilizing dynamically exposed ports and the Docker host IP.
  • Refactored get_connection_string: The main method now dispatches to the appropriate internal function based on the ConnectionStringType provided.
  • Improved get_external_connection_string: This method has been enhanced to intelligently prioritize network aliases for inter-container communication and provide a robust fallback to the Docker host IP for other scenarios.
  • Comprehensive Unit Test: A new test case, test_azurite_inter_container_communication_with_network_string, has been added to thoroughly validate both network-based and local host-based connection string functionality.
  • Enhanced Docstrings: All relevant methods within AzuriteContainer and the associated example application (network_container.py) have received updated and more detailed docstrings for improved clarity and usage guidance.

Testing

To validate these functionalities, the new test case test_azurite_inter_container_communication_with_network_string was introduced. This test specifically verifies:

  • Inter-container communication: An external application container successfully connects to Azurite using the NETWORK connection string (via its network alias) and performs an operation (e.g., creates a blob container).
  • Local host access verification: The operation performed by the external container is then successfully verified from the local test machine using the LOCALHOST connection string, confirming data persistence and accessibility.

Concerns and Questions

As this is my first contribution to this repository, I've aimed for comprehensive docstrings and clear code. I'm open to feedback on their level of detail, adherence to project conventions, or any other aspect of the implementation.

Please let me know if any further changes or clarifications are needed.

Add functionality to generate Azurite connection strings suitable for direct container-to-container communication within a Docker network, alongside existing local host access.

Key changes include:
- Introduces `ConnectionStringType` enum to provide distinct Azurite
connection strings for different access patterns:
   - `NETWORK`: Optimized for inter-container communication using network aliases.
   - `LOCALHOST`: For access from the host machine via exposed ports.
- Refactored `get_connection_string` to dispatch based on `ConnectionStringType`.
- Improved `get_external_connection_string` to prioritize network aliases nd provide a fallback to host IP.
- Added comprehensive unit test (`test_azurite_inter_container_communication_with_network_string`)
  to verify inter-container connectivity.
Copy link

codecov bot commented Aug 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@d40473f). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #859   +/-   ##
=======================================
  Coverage        ?   81.79%           
=======================================
  Files           ?       14           
  Lines           ?      890           
  Branches        ?      140           
=======================================
  Hits            ?      728           
  Misses          ?      127           
  Partials        ?       35           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@adendek adendek requested a review from alexanderankin August 12, 2025 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Question: Communication between azurite container and custom one
2 participants